const express=require("express");
const bodyParser=require("body-parser");
const mongoose=require("mongoose")
const app=express();
//连接数据库
const db=require("./config/key").mongoUrl;
const router=require("./router/router");
mongoose.connect(db,{useNewUrlParser: true,useUnifiedTopology: true})
    .then(()=>console.log("Mongodb Connected Success"))
	.catch((err)=>console.log(err));
	
//使用bodyparser中间键方便使用post请求
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());
app.use("/",router);
app.listen(5000,function(){
	console.log("server connection successful please visit http://localhost:5000")
})